import request from '@/utils/request/request';
import type { SleepReport, SleepReportRequestParams } from '@/types/sleepReport';
import type { CommonResponse } from '@/types/response';

// 获取睡眠报告列表
export const listSleepReport = (params?: Partial<SleepReport>): Promise<CommonResponse<SleepReport[]>> => 
  request.get('/sleep/report/list',  params );

// 获取 APP 端睡眠报告列表
export const appListSleepReport = (params?: Partial<SleepReportRequestParams>): Promise<CommonResponse<SleepReport[]>> => 
  request.get('/sleep/report/app/list',  params );

// 获取睡眠报告详情
export const getSleepReportInfo = (reportId: number): Promise<CommonResponse<SleepReport>> => 
  request.get(`/sleep/report/${reportId}`);

// 新增睡眠报告
export const addSleepReport = (sleepReport: Omit<SleepReport, 'id'>): Promise<CommonResponse<SleepReport>> => 
  request.post('/sleep/report', sleepReport);

// 编辑睡眠报告
export const editSleepReport = (sleepReport: SleepReport): Promise<CommonResponse<SleepReport>> => 
  request.put('/sleep/report', sleepReport);

// 删除睡眠报告
export const removeSleepReport = (ids: number[]): Promise<CommonResponse<void>> => 
  request.delete(`/sleep/report/${ids.join(',')}`);

